<template>
	<view class="container">
		<NavBar title="购物车" :isFixed="true" :isBack="false"></NavBar>
		<view class="handleWrap" :style="{'top':statusBarHeight+navBarHeight + 'px'}">
			<text class="cartNum" >共{{cartLen}}件宝贝</text>
			<text class="handle" @click="handleCart">{{handleStatus?'完成':'管理'}}</text>
		</view>
		<CartList ref="cartList" :isShowTotal="handleStatus" @giveCartLen="getCartLen"></CartList>
	</view>
</template>

<script>
	import {mixin} from '@/common/mixin'
	import {checkToken} from '@/common/checkAuth'
	import CartList from './components/CartList'
	export default {
		mixins:[mixin],
		components:{
			CartList
		},
		data() {
			return {
				cartList:[],
				cartLen:0,
				handleStatus: false
			}
		},
		onShow(){
			if(checkToken('/pages/My/My')){
				this.$nextTick(()=>{
					this.$refs.cartList.getCart()
				})
			}
		},
		methods: {
			getCartLen(len){
				this.cartLen = len
			},
			handleCart () {
				this.handleStatus = !this.handleStatus
			}
		}
	}
</script>

<style lang="scss" scoped>
.container{
	min-height: 100%;
	display: flex;
	flex-direction: column;
	background-color: rgb(244,244,244);
	font-size: 24rpx;
	.handleWrap{
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		position: fixed;
		left: 0;
		z-index: 99;
		background-color: #fff;
		.cartNum {
			color: rgb(110, 110, 110);
		}
		.handle {
			font-size: 28rpx;
			color: rgb(87, 87, 87);
			font-weight: bold;
		}
	}
}

</style>
